package com.atguigu.tingshu.user.strategy.paid;

import com.atguigu.tingshu.common.execption.GuiguException;
import com.atguigu.tingshu.common.result.ResultCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@Slf4j
public class PaidRecordContext {
    @Autowired
    private Map<String , PaidRecordStrategy> paidRecordStrategyMap;

    public PaidRecordStrategy getPaidRecordStrategy(String itemType){
        if(!paidRecordStrategyMap.containsKey(itemType)){
            throw new GuiguException(ResultCodeEnum.ARGUMENT_VALID_ERROR);
        }
        return paidRecordStrategyMap.get(itemType);
    }
}
